package me.wangqu.weiyouqu.web.rest;

import me.wangqu.weiyouqu.web.rest.business.model.ListModel;
import me.wangqu.weiyouqu.web.rest.business.service.VideoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by joln on 2016/7/11.
 */
@RestController
@RequestMapping(value = "/api")
public class VideoResource {
    private final Logger log = LoggerFactory.getLogger(VideoResource.class);

    @Autowired
    private VideoService videoService;

    @RequestMapping(value = "/videos",
        method = RequestMethod.GET,
        produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<ListModel> getCodeVideo(Integer code, Integer type, Pageable pageable) {
        if (type == 3) {
            return new ResponseEntity<>(videoService.getCodeVideo(code, type, pageable), HttpStatus.OK);
        }
        return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
    }


}
